
package svl;


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.ClienteBean;

import client.controlador.Controlador;




/**
 * Servlet implementation class ParametrosCliente
 */
public class ParametrosCliente extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ParametrosCliente() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		String cuit = request.getParameter("cuit");
		
		ClienteBean cliente = Controlador.getInstancia().obtenerCliente(cuit);
		String dire = null;
		if(cliente ==null)
		{
			System.out.println("Cliente NOO Existe");
			dire ="/WEB-INF/jsp/ClienteNull.jsp";
			request.setAttribute("cuit",cuit);
		}
		else
		{
			System.out.println("Cliente Existe");
			dire ="/WEB-INF/jsp/opciones.jsp";
			 request.setAttribute("cuit",cliente.getCuit());
			    request.setAttribute("nombre",cliente.getNombre());
			    request.setAttribute("domicilio",cliente.getDomicilio());
		}
		
		
		System.out.println(request.getParameterMap());

		
		
		
	    response.setContentType("text/html");
	    
	   
		RequestDispatcher dispatcher = request.getRequestDispatcher(dire);
		dispatcher.forward(request, response);
	    
	   
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}